<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>不合格产品查询</title>
    <link rel="stylesheet" href="layui/css/layui.css">
    <link rel="stylesheet" href="css/base.css">
    <style>
        #Contents .c_right {
        width: 100%;
        height: 100%;
        
    }
    .addProcess input{
    width: 80%;
    height: 100%;
    font-size: 18px;
   }
   .addProcess select{
	 width: 81%;
    height: 100%;
    font-size: 18px;
	}
	button{
	height: 50px;
    width: 125px;
    background: #3085be;
    font-size: 15px;
    color: #fff;
    line-height: 50px;
    border-radius: 10px;
    margin-top: 50px;
	}
	 #Contents {
	 	 text-align: center;
	 }
    </style>
</head>

<body>
    <div id="Contents">
        <div class="c_right">
            <table border="1" cellspacing="0" class="addProcess">
                <caption>不合格产品查询</caption>
                <tr>
                    <th>工序</th>
                    <td>
                        <select  id="select">

                        </select>
                    </td>
                    <th>生产线号</th>
                    <td><input type="text" class="productlineNum"></td>
                </tr>
                <tr>
                    <th>开始时间</th>
                    <td><input type="text" id="start"></td>
                    <th>结束时间</th>
                    <td><input type="text" id="end"></td>
                </tr>
                <tr>
                    <th>设备编号</th>
                    <td><input type="text" class="deviceNum"></td>
                    <th>生产批次号</th>
                    <td><input type="text" class="batch"></td>
                </tr>
                <tr>
                    <th>工位号</th>
                    <td><input type="text" class="stationNum"></td>
                    <th>员工条码</th>
                    <td><input type="text" class="employeeCode"></td>
                </tr>
            </table>
        </div>
        <button>确定</button>
    </div>
    <script src="js/jquery-1.10.1.min.js"></script>
    <script src="layui/layui.all.js"></script>
    <script>
    /**
      查询所有工序
    **/
    function getProcess() {
        $.ajax({
                // url: '../json/getProcess.json',
                url: 'http://localhost:8080/getProcess',
                type: 'get',
                // dataType: 'default: Intelligent Guess (Other values: xml, json, script, or html)',
                // data: { method: 'getProcess' },
            })
            .done(function(data) {
            	$("#select").empty();
                console.log("getProcess");
                var data = data.data;
                var html = "";
                for (var i = 0; i < data.length; i++) {
                    html += `<option>${data[i]}</option>`;
                }
                $(html).appendTo('#select');
            })
            .fail(function() {
                console.log("error");
            })
    }
    getProcess();
    layui.use('laydate', function() {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });
    });
    layui.use('laydate', function() {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });
    $("button").click(function(event) {
        /* Act on the event */
        var processName=$("#select").val();
        var productlineNum=Number($(".productlineNum").val());
        var startTime=$("#start").val();
        var endTime=$("#end").val();
        var deviceNum=Number($(".deviceNum").val());
        var batch=$(".batch").val();
        var stationNum=Number($(".stationNum").val());
        var employeeCode=$(".employeeCode").val();
        // var data={
        // 	processName:processName,
        // 	productlineNum:productlineNum,
        // 	startTime:startTime,
        // 	endTime:endTime,
        // 	deviceNum:deviceNum,
        // 	batch:batch,
        // 	stationNum:stationNum,
        // 	employeeCode:employeeCode
        // };
        // var d=JSON.stringify(data);
        // window.localStorage.setItem("openBad", d);
        var index = parent.layer.getFrameIndex(window.name);
        console.log(window.parent)
        // window.parent.getBadPro();
         window.parent.getBadPro(processName, productlineNum, startTime, endTime, deviceNum, batch, stationNum, employeeCode);
         parent.layer.close(index);

    });
    </script>
</body>

</html>